// page/coachs/member/index.js
Page({
  data: {
    isHide: false,
    navIndex: 3,
    thumb: '',
    nickname: '',
    studentStudying: 0,
    uid:0,
  },
  onLoad: function (options) {
    var that = this;
    getApp().getUserOpenId(
      function (uid) {
        console.log("回调1")
        console.log(uid)
        that.uid=uid
        wx.request({
          url: getApp().globalData.host + "&m=Coach&a=My", //仅为示例，并非真实的接口地址
          data: {
            "uid": uid
          },
          header: {
            'content-type': 'application/json', // 默认值
          },
          method: "POST",
          success: function (res) {
            console.log(res.data)
            //请求成功
            if (res.data.status == 1) {
              that.setData({
                isHide: true,
                data: res.data
              })
            } else {//请求失败
              wx.showToast({
                title: res.data.info,
              })
            }
          },
          fail: function (res) {
            wx.showToast({
              title: "请求失败",
            })
          }
        })
      },
      function (info) {
        console.log("回调2")
        console.log(info)
        that.setData({
          thumb: info.avatarUrl,
          nickname: info.nickName,
        })
      }
    )
  }
})